package com.egame.manage.biz.server.cu;

import java.rmi.RemoteException;
import java.util.List;
import java.util.Map;

import cn.egame.common.exception.ExceptionCommonBase;
import cn.egame.common.model.PageData;
import cn.egame.ext.cu.ManufactureInfo;
import com.egame.manage.biz.server.ManageClientExt;
import com.egame.manage.biz.domain.ManufactureBean;

public class ManufacturerServiceImpl {
	private static ManufacturerServiceImpl instance = null;
	private static byte[] SyncRoot = new byte[1];
	private ManufacturerServiceDao dao = null;
	
	public static ManufacturerServiceImpl getInstance() throws ExceptionCommonBase {
		if (instance == null) {
			synchronized (SyncRoot) {
				if (instance == null) {
					instance = new ManufacturerServiceImpl();
				}
			}
		}
		return instance;
	}

	public ManufacturerServiceImpl() throws ExceptionCommonBase {
		super();
		this.dao = new ManufacturerServiceDao();
	}
	
	public int setManufactureInfo(int appId,long loginUserId,ManufactureBean item) throws ExceptionCommonBase{		
		return dao.setManufactureInfo(item);
	}
	
	public int  deleteManufacturer(int appId,long loginUserId,int manufacturerId) throws ExceptionCommonBase{
		return dao.deleteManufacturer(manufacturerId);
	}
	
	public int updateManufactureInfo(int appId,long loginUserId,ManufactureInfo bean)throws ExceptionCommonBase{
		return dao.updateManufactureInfo(bean);
	}
	
	public Map<String, Object> listManufacturer(int appId,long loginUserId)throws ExceptionCommonBase{
		return dao.listManufacturer();
	}
	
	public List<String[]> listManufacturerBand(int appId,long loginUserId)throws ExceptionCommonBase{
		return dao.listManufacturerBand();
	}
	
	public String getManufactureName(int appId,long loginUserId,int mId)throws RemoteException{
		return dao.getManufactureName(appId, loginUserId, mId);
	}
	
	public PageData pageManufacture(int appId,long loginUserId,ManufactureInfo bean,int page,int rowsOfPage)throws RemoteException{
		List<Integer> ids = dao.listManufacturer(bean,page,rowsOfPage);
		List<ManufactureInfo> list = ManageClientExt.getInstance().listManufactureInfoByIds(appId, loginUserId, ids);
		int total = dao.getCount(bean);
		PageData pd = new PageData(page, total, rowsOfPage);
		pd.setContent(list);
		return pd;		
	}

	public ManufactureInfo getManufactureInfo(int appId,long loginUserId,int id)throws RemoteException{
		ManufactureInfo bean = ManageClientExt.getInstance().getManufactureInfoById(appId, loginUserId, id); 
		return bean==null?new ManufactureInfo():bean;
	}
	
}
